package me.jzn.alib.compat;

import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;

import androidx.annotation.DrawableRes;

/**
 * @author xqs @date 2020/3/26
 * 因为drawable可能是resid，Uri(包括sdk和http),drawable
 * 如果有些地方，比如头像，可以用这个接口来统一一下
 */
public interface CompatImage {
    public class ResImage implements CompatImage {
        @DrawableRes int resId;

        public ResImage(@DrawableRes int resId) {
            this.resId = resId;
        }

        @DrawableRes
        public int getResId() {
            return this.resId;
        }
    }

    public class UriImage implements CompatImage {
        private Uri uri;

        public UriImage(Uri uri) {
            this.uri = uri;
        }

        public Uri getUri() {
            return this.uri;
        }
    }

    public class BitmapImage implements CompatImage {
        private Bitmap bitmap;

        public BitmapImage(Bitmap bitmap) {
            this.bitmap = bitmap;
        }

        public Bitmap getBitmap() {
            return this.bitmap;
        }
    }

    public class DrawableImage implements CompatImage {
        private Drawable drawable;

        public DrawableImage(Drawable drawable) {
            this.drawable = drawable;
        }

        public Drawable getDrawable() {
            return this.drawable;
        }
    }
}
